<?php
if ($_GET['type'] == 'lic') {
	if (preg_match('/[a-z0-9]{32,32}/', $_GET["softid"]) & preg_match('/^[\x{4e00}-\x{9fa5}A-Za-z0-9_]{1,15}+$/u', $_GET["username"])) {
		include "islogin.php";
		if ($is_log == "1") {
			setcookie("nickname", $nickname, time() - 180000, "/");
			setcookie("check", $checkcode, time() - 180000, "/");
			echo "1";
		} else {
			include "getuid.php";
			include 'setting.php';
			$con = mysqli_connect($sqldatabase, $sqlusername, $sqlpassword,$sqltable);
			mysqli_query($con,'set names utf8'); 
			mysqli_query($con,"INSERT INTO softlic (uid,softid,usertoken,usernam,is_can) VALUES ('" . $uid . "','" . $_GET["softid"] . "', '" . md5(time() . rand() . "addsoftlic!!!!") . "', '" . $_GET["username"] . "', '0')");
			echo "0";
			mysqli_close($con);
		}
	}
} else if ($_GET['type'] == 'soft') {
	
	if (preg_match('/\d+\.\d+\.\d+.\d+/', $_GET["version"]) & preg_match('/^[\x{4e00}-\x{9fa5}A-Za-z0-9_]{1,15}+$/u', $_GET["softname"]) & preg_match('/^[\x{4e00}-\x{9fa5}A-Za-z0-9_]{1,100}+$/u', $_GET["description"])) {
		include "islogin.php";
		if ($is_log == "1") {
			setcookie("nickname", $nickname, time() - 180000, "/");
			setcookie("check", $checkcode, time() - 180000, "/");
			echo "1";
		} else {
			include "getuid.php";
			include 'setting.php';
			$con = mysqli_connect($sqldatabase, $sqlusername, $sqlpassword,$sqltable);
			mysqli_query($con,'set names utf8'); 
			mysqli_query($con,"INSERT INTO softlist (uid,version,softid,softname,description,CheckNum) VALUES ('" . $uid . "','" . $_GET["version"] . "', '" . md5(time() . rand() . "addsoftclient!!!!") . "', '" . $_GET["softname"] . "', '" . $_GET["description"] . "','0')");
			echo "0";
			mysqli_close($con);
		}
	}
}
else
	{
		echo 'BAD REQUEST!PLEASE TRY AGAIN!';
	}
?>